#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created by master on 2017/2/26
import time


# 消费包子
def consumer(name):
    while True:
        print("%s is 吃包子辣" % name)
        baozi = yield  # yield接收值

        print("包子[%s]来了，被[%s]吃了！" % (baozi, name))


# 生产包子
def producer():
    c = consumer("A")
    c2 = consumer("B")

    c.__next__()
    c2.__next__()

    print("老子开始准备做包子啦")

    for i in range(10):
        time.sleep(1)
        print("做了两个包子！")
        c.send(i)
        c2.send(i)  # send方法 把值传给yield


producer()
